package com.daykw.xiaohongshu.util;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import org.nutz.dao.Cnd;
import org.nutz.dao.impl.NutDao;

import com.daykw.xiaohongshu.model.Ips;


public class IPPoolMap {
	private static BlockingQueue<Ips> queue = new ArrayBlockingQueue<Ips>(2000);
	// private static BlockingQueue<Ips> tqueue = new
	// ArrayBlockingQueue<Ips>(1000);
	// private static ConcurrentMap<String, Ips> queue = new
	// ConcurrentHashMap<String, Ips>();

	private static NutDao dao = SpringContextHolder.getBean("dao");

	// public static BlockingQueue<Ips> getTaskQueue() {
	// return tqueue;
	// }
	//
	// public static BlockingQueue<Ips> getArticleQueue() {
	// return aqueue;
	// }
	public static BlockingQueue<Ips> getQueue() {
		return queue;
	}

	public static void removeIp(String ips) {
		try {
			EhcacheUtils.getInstance().putCache(ips, ips);
			//dao.clear(Ips.class, Cnd.where("ips", "=", ips));
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	// public static ConcurrentMap<String, Ips> getQueue() {
	// return queue;
	// }
	//
	// public static Ips getIp() {
	// if (queue.keySet().size() > 0) {
	// String[] keys = queue.keySet().toArray(new String[0]);
	// Random random = new Random();
	// String randomKey = keys[random.nextInt(keys.length)];
	// Ips val = queue.get(randomKey);
	// return val;
	// } else {
	// return null;
	// }
	//
	// }

}
